﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ORM.Util
{
    public static class ConfigUtil
    {
        public static bool IsTraceOvertTimeSQL()
        {
            return Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["FastORM_TraceOvertTimeSQL"]) == "1" ? true : false;
        }

        public static int GetTraceOverTimeLimit()
        {
            return Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["FastORM_TraceOverTimeLimit"]);
        }

        public static string GetServer(string ConnectStringName)
        {
            string ConnectString = System.Configuration.ConfigurationManager.ConnectionStrings[ConnectStringName].ConnectionString;
            return ConnectString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)[1].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[1];
        }

        public static string GetDataBase(string ConnectStringName)
        {
            string ConnectString = System.Configuration.ConfigurationManager.ConnectionStrings[ConnectStringName].ConnectionString;
            return ConnectString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)[0].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[1];
        }

        public static string GetUUID()
        {
            return DateTime.Now.ToString("yyyyMMddHHmmss") + Guid.NewGuid().ToString();
        }
    }
}
